package com.sjtu.service.login;

import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * nerine
 * 2/7/2020
 */
@Getter
@Setter
public class LoginToken {
    private String token;
    private Date createdDate;
    private int expiredSeconds;

    public boolean isExpired(Date now) {
        return LocalDateTime.ofInstant(createdDate.toInstant(), ZoneId.systemDefault())
                .plusSeconds(expiredSeconds).isBefore(LocalDateTime.ofInstant(now.toInstant(), ZoneId.systemDefault()));
    }
}
